package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.CategorytypeQuery;
import com.gec.zhs.entity.po.Categorytype;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.CategorytypeService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 分类类型 Controller
 */
@RestController("categorytypeController")
@RequestMapping("/categorytype")
public class CategorytypeController extends ABaseController{

	@Resource
	private CategorytypeService categorytypeService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(CategorytypeQuery query){
		return getSuccessResponseVO(categorytypeService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Categorytype bean) {
		categorytypeService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Categorytype> listBean) {
		categorytypeService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Categorytype> listBean) {
		categorytypeService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getCategorytypeById")
	public ResponseVO getCategorytypeById(String id) {
		return getSuccessResponseVO(categorytypeService.getCategorytypeById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateCategorytypeById")
	public ResponseVO updateCategorytypeById(Categorytype bean,String id) {
		categorytypeService.updateCategorytypeById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteCategorytypeById")
	public ResponseVO deleteCategorytypeById(String id) {
		categorytypeService.deleteCategorytypeById(id);
		return getSuccessResponseVO(null);
	}
}